﻿package mortal.game.view.halidom.view
{
    import com.gengine.global.*;
    import com.mui.containers.globalVariable.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import flash.geom.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.view.common.*;
    import mortal.game.view.halidom.render.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class HalidomWayFindingView extends View
    {
        private var _bg:ScaleBitmap;
        private var _list:GTileList;
        private static var _instance:HalidomWayFindingView;

        public function HalidomWayFindingView()
        {
            this.layer = GameController.halidom.view as ILayer;
            return;
        }// end function

        private function onStageMouseDown(event:MouseEvent) : void
        {
            var _loc_3:Boolean = false;
            var _loc_4:DisplayObject = null;
            var _loc_2:* = Global.stage.getObjectsUnderPoint(new Point(Global.stage.mouseX, Global.stage.mouseY));
            for each (_loc_4 in _loc_2)
            {
                
                if (_loc_4.name == "HalidomWayFindingViewBg")
                {
                    _loc_3 = true;
                    break;
                }
            }
            if (_loc_3 == false)
            {
                hide();
            }
            return;
        }// end function

        public function set maps(param1:String) : void
        {
            var _loc_2:* = param1.split("#");
            this._list.dataProvider = new DataProvider(_loc_2);
            this._list.drawNow();
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            var _loc_3:* = DisplayObject(this.layer).globalToLocal(new Point(Global.stage.mouseX, Global.stage.mouseY));
            super.show(_loc_3.x, _loc_3.y - 90);
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bg = UIFactory.bg(0, 0, 225, 100, this, ImagesConst.ToolTipBg);
            this._bg.name = "HalidomWayFindingViewBg";
            this._list = UIFactory.tileList(10, 10, 218, 140, this);
            this._list.setStyle("cellRenderer", HalidomWayFindingViewRenderer);
            this._list.columnWidth = 198;
            this._list.rowHeight = 33;
            this._list.direction = GBoxDirection.VERTICAL;
            Global.stage.addEventListener(MouseEvent.MOUSE_DOWN, this.onStageMouseDown);
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl(param1);
            Global.stage.removeEventListener(MouseEvent.MOUSE_DOWN, this.onStageMouseDown);
            this._bg.dispose(param1);
            this._list.dispose(param1);
            return;
        }// end function

        public static function get instance() : HalidomWayFindingView
        {
            if (_instance == null)
            {
                _instance = new HalidomWayFindingView;
            }
            return _instance;
        }// end function

    }
}
